package com.example.leetdemo.finash;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Solution1403 {

    public List<Integer> minSubsequence(int[] nums) {
        List<Integer> list = new ArrayList<>();
        int sum  = Arrays.stream(nums).sum();
        Arrays.sort(nums);
        int mind = sum / 2;
        int count = 0;
        for (int i = nums.length - 1; i >= 0; i--) {
            count += nums[i];
            list.add(nums[i]);
            if (count > mind) {
                break;
            }
        }
        return list;
    }

}
